clear
set type double
set more 1

***************************************
*NOTES
*Online appendix table B5 - robustness of export currency choice
*********************************************************************

capture log using log/OnlineAppendixTableB5_xchoice_combined.log, replace

use ../data/xcurrencychoice_estdata, clear

**********************************
*merge on additional data
	merge m:1 cty_code using temp/world_bank, keep(match master) nogen
	merge m:1 vat hs4 using temp/main, keep(match master) 
	gen main=_merge==3
	drop _merge

	merge m:1 hs6 using ../data/Rauch_hs6_concordance, keep(match master) 
	gen dif=con=="n" if _merge==3
	drop _merge
	merge m:1 cty_code using ../data/usd_peg, keep(match master) nogen
	merge m:1 cty_code using ../data/exports_country, keep(match master) nogen
	merge m:1 hs4 using ../data/exports_HS4, keep(match master) nogen
	
	gen lngdp_percap=ln(gdp_percap)	

*merge in additional variables
*firm-level variables
	merge m:1 vat using ../data/Additional_Variables, keep(match master) nogen
	replace coverage=coverage/100
	replace shRD=0 if missing(shRD)
	gen lnassets=ln(tot_assets)

*********************************************************
*ESTIMATION
***********************************************

******************************************
*appendix table B3 - kitchen sink approach
**********************************************

*col1: baseline for reference
	eststo: reghdfe Ix mphi_xeu lnmemp ms, absorb(cp date) cluster(vat) 
	
*col2: combined real variables
	eststo: reghdfe Ix mphi_xeu lnmemp ms ez_exportsh exports_sales inFDI outFDI shRD lntfp_n, absorb(cp date) cluster(vat) 
	
*col3: combined financial variables
	eststo: reghdfe Ix mphi_xeu lnmemp ms cash_STdebt coverage leverage, absorb(cp date) cluster(vat) 
	
*col4: combined all
	eststo: reghdfe Ix mphi_xeu lnmemp ms ez_exportsh exports_sales inFDI outFDI shRD lntfp_n cash_STdebt coverage leverage, absorb(cp date) cluster(vat) 
	

esttab using "../results/AppendixTableB5_xchoice_combined.csv", se  b(3) se(3) r2 ar2 star(* 0.10 ** 0.05 *** 0.01) compress replace
eststo clear


log close
	
